/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-10-05
 * Time:21:37
 */

/**
 * 力扣剑指offer11:旋转数字的最少数字
 */

public class minArray {
    public int minArray(int[] numbers) {
        //最开始的若干个元素搬到数组的末尾，我们称之为数组的旋转
        //可能存在 重复 元素值的数组
        //原来是一个升序排列的数组
        //进行了一次旋转
        //二分查找
        int low = 0;
        int high = numbers.length - 1;
        while(low < high){
            int mid = low + (high - low)/2;
            if(numbers[mid] < numbers[high]){
                high = mid;
            }else if(numbers[mid] > numbers[high]){
                low = mid + 1;
            }else{
                high = high - 1;
            }
        }
        return numbers[low];
    }
}
